package com.fdb.smcts.core.threadpool;

import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ApplicationThreadPool2 {
	private static final Logger logger = LoggerFactory.getLogger(ApplicationThreadPool2.class);
	
	private final ThreadPoolExecutor threadpool;
	
	public ApplicationThreadPool2(Integer maxThread) {
		threadpool = (ThreadPoolExecutor) Executors.newFixedThreadPool(maxThread);
		logger.info("线程池已初始化！，线程池大小：" + maxThread);
	}

	public void add(Callable<ExecuteRtnInfo> task) {
		threadpool.submit(task);
	}

	public void add(Runnable task) {
		threadpool.execute(task);
	}

	public void change(Integer newThreadNum) {
		threadpool.setMaximumPoolSize(newThreadNum);
	}
}
